package com.xiangyi.teachingsystem.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiangyi.teachingsystem.entity.dto.PrivateResUserInfoDto;
import com.xiangyi.teachingsystem.entity.po.PrivateResShare;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PrivateResShareMapper extends BaseMapper<PrivateResShare> {
    @Select("SELECT prs.id,pr.res_name,pr.res_address,pr.res_sub,pr.res_major,pr.res_major,pr.res_course,pr.res_size,u.`name`,u.job_num\n" +
            "FROM private_res_share prs\n" +
            "LEFT JOIN private_res pr\n" +
            "ON prs.res_id=pr.id\n" +
            "LEFT JOIN `user` u\n" +
            "ON pr.user_id=u.id\n" +
            "WHERE prs.user_id=#{userId}")
    List<PrivateResShare> getShearedResList(Integer userId);

    @Select("SELECT prs.id,pr.res_name,pr.res_address,pr.res_sub,pr.res_major,pr.res_course,pr.res_size,u.id `user_id`,u.`name`,u.job_num\n" +
            "FROM private_res_share prs\n" +
            "LEFT JOIN private_res pr\n" +
            "ON prs.res_id=pr.id\n" +
            "LEFT JOIN `user` u\n" +
            "ON u.id=prs.user_id\n" +
            "WHERE pr.user_id=#{userId}")
    List<PrivateResShare> getSheareResList(Integer userId);

    @Select("SELECT prs.id prs_id,pr.public_sign,u.id user_id,u.`name`,u.phone_num,u.head_url,u.job_num\n" +
            "FROM private_res_share prs\n" +
            "LEFT JOIN `user` u\n" +
            "ON u.id=prs.user_id\n" +
            "LEFT JOIN private_res pr\n" +
            "ON pr.id=prs.res_id\n" +
            "WHERE prs.res_id=#{resId}")
    List<PrivateResUserInfoDto> getShareUsersListByResId(Integer resId);
}
